package org.zhouhe.base;

import java.util.Map;

import javax.servlet.ServletContext;

import org.apache.struts2.ServletActionContext;
import org.apache.struts2.interceptor.ApplicationAware;
import org.apache.struts2.interceptor.RequestAware;
import org.apache.struts2.interceptor.SessionAware;
import org.zhouhe.util.Constant;
import org.zhouhe.vo.User;

import com.opensymphony.xwork2.ActionSupport;

@SuppressWarnings("serial")
public class BaseAction extends ActionSupport implements RequestAware, SessionAware, ApplicationAware {
	protected Map<String, Object> requestMap;
	protected Map<String, Object> sessionMap;
	protected Map<String, Object> applicationMap;
	protected ServletContext servletContext;
	private String pageTitle;
	private String pageKeywords;
	private String websiteName = "中国市场与产业研究网";
	{
		servletContext  = ServletActionContext.getServletContext();
	}
	protected Integer operationStatus = 0;//操作执行结果：1成功；0不成功；-1无权限
	protected String RESULT_OUTPUT_STATUS = "result_output_status";

	public void setRequest(Map<String, Object> requestMap) {
		this.requestMap = requestMap;
	}

	public void setSession(Map<String, Object> sessionMap) {
		this.sessionMap = sessionMap;
	}

	public void setApplication(Map<String, Object> applicationMap) {
		this.applicationMap = applicationMap;
	}

	public void setOperationStatus(Integer operationStatus) {
		this.operationStatus = operationStatus;
	}

	public Integer getOperationStatus() {
		return operationStatus;
	}
	public User getCurrentUser(){
		User userDetail = (User) sessionMap.get(Constant.SESSION_KEY_USER_INFO);
		return userDetail;
	}

	public void setPageKeywords(String pageKeywords) {
		this.pageKeywords = pageKeywords;
	}

	public String getPageKeywords() {
		return pageKeywords;
	}

	public void setPageTitle(String pageTitle) {
		this.pageTitle = pageTitle;
	}

	public String getPageTitle() {
		return pageTitle;
	}

	public void setWebsiteName(String websiteName) {
		this.websiteName = websiteName;
	}

	public String getWebsiteName() {
		return websiteName;
	}
}
